package demo02fahongbao;

import java.util.ArrayList;
import java.util.Random;

public class Admin extends User {
    public Admin() {
    }

    public Admin(String name, int money) {
        super(name, money);
    }

    public ArrayList<Integer> send(int totalmoney, int count) {
        ArrayList<Integer> redList = new ArrayList<>();
        int leftMoney = super.getMoney();
        if (leftMoney < totalmoney) {
            System.out.println("余额不足");
            return redList;
        }
        //扣钱
        super.setMoney(leftMoney - totalmoney);

        int all=totalmoney;
        for (int i = 0; i < count-1; i++) {
            int current=new Random().nextInt(all-2)+1;//结果为1~(all-1)
            redList.add(current);
            all=all-current;
        }
        redList.add(all);

        return redList;

    }
}















